package poo.recursion;

public class Potenza {
	public static void main( String[] args ){
		System.out.println("2^50="+potenza(2,50));
		System.out.println("2^50="+(long)Math.pow(2,50));
	}//main
	static long potenza( int a, int n ){
		if( n==0 ) return 1;
		if( n==1 ) return a;
		long p=potenza( a, n/2 );
		p=p*p;
		if( n%2!=0 ) p*=a;
		return p;
	}
}//Potenza
